import Vue from 'vue'
import VueRouter from 'vue-router'
import managelogin from '../components/managelogin.vue'
import manageforget from '../components/manageforget.vue'
import managehome from '../components/managehome.vue'
// import managewelcome from '../components/welcome.vue'
import RegistInformation from '../components/RegistInformation.vue'
import manageregiste from '../components/manageregiste.vue'
// import manageinformation from '../components/manageinformation.vue'

Vue.use(VueRouter)

const routes = [
    { path: '/', redirect: '/managelogin' },
    { path: '/managelogin', component: managelogin },
    { path: '/manageregiste', component: manageregiste },
    { path: '/manageforget', component: manageforget },
    {
        path: '/managehome',
        component: managehome,
        redirect: '/RegistInformation',
        children: [
            { path: '/RegistInformation', component: RegistInformation },
        ]
    }
]

const router = new VueRouter({
    routes
})

//路由守卫
// router.beforeEach((to,from,next) =>{
//   if(to.path === '/login'&&to.path === '/forget'){
//     return next()
//   }
//   else if(!window.localStorage.getItem('token')) {
//     Message.error('您还没有登录，请登录')
//     return next('/login')
//   }
//   next()
// })

// router.beforeEach((to, from, next) => {
// to 将要访问的路径
// from 代表从那个路径跳转的
// next 是一个函数，表示放行
//   next 放行      next("/login")  强制跳转
//   if (to.path === '/login') return next();
//   if (to.path === '/forget') return next();

//   const tokenStr = window.localStorage.getItem('token')
//   if (!tokenStr) {
//     return next('/login')
//   }
//   else {
//     return next()
//   }
// })
export default router